daemon: allow configuring initial interests#732
Conversation
556f8cd to
1f6ea28
Compare
dav1do
left a comment
There was a problem hiding this comment.
Looks good. I have a few small things/questions but nothing blocking.
| value_delimiter = ',', | ||
| env = "CERAMIC_ONE_INITIAL_INTERESTS" | ||
| )] | ||
| initial_interests: Vec<String>, |
There was a problem hiding this comment.
nit: trying to decide what this name should be.. it's not exactly "initial" because they don't ever go away, but NEW or MODEL steams a bit silly
There was a problem hiding this comment.
also, I wonder if we want to subscribe to the METAMODEL_STREAM_ID automatically/easily? unless we do and I missed it, but that's the "I'd like to see all models on the network".
There was a problem hiding this comment.
EXTRA_INTERESTS kinda matches how the daemon treats "appending" peers, so I'll go with that 👌
There was a problem hiding this comment.
also, I wonder if we want to subscribe to the
METAMODEL_STREAM_IDautomatically/easily? unless we do and I missed it, but that's the "I'd like to see all models on the network".
Myeah, but for testing scenarios it's also pretty useful to have an "idle" node by default. I'll leave automatic MM interest registration out for now, but add the MM id to the config docs on this flag.
| let result = | ||
| process_initial_interests(&stream_ids, &interest_svc, &network, &node_id).await; | ||
| // Should succeed with proper multibase decoding | ||
| assert!(result.is_ok()); |
There was a problem hiding this comment.
nit: maybe add an assertion this was written to the db?
let vals = interest_svc.full_range().await.unwrap();
assert!(vals.count(), 1);| let stream_id_bytes = multibase::decode(stream_id_str) | ||
| .map_err(|e| anyhow!("Failed to decode stream ID '{}': {}", stream_id_str, e))? | ||
| .1; | ||
| let start = EventId::builder() |
There was a problem hiding this comment.
I was considering if it'd be worth putting this in interest service or core so we could share most of this with the http server. But I think this API is fine to be exposed, I just couldn't remember how to build interest ranges and wanted a higher level API that's like subscribe_to_model 😅
There was a problem hiding this comment.
Yeah I agree, but it's not entirely clear how to do that so I'll leave it for now
1f6ea28 to
ba5e12f
Compare
ba5e12f to
8c19950
Compare
|
Closed in favour of #734 |
This PR implements a new CLI flag
--initial-interests(and envvarCERAMIC_ONE_INITIAL_INTERESTS) to automatically register node interests when starting the daemon, eliminating the need for manual API calls after startup.Changes
--initial-interests, accepting comma-separated stream/model IDsone/src/startup.rsto orchestrate daemon configuration tasks tangential to the startup processInterestService/ceramic/interestsAPI handlerSafety & backward compatibility
Usage
Flag
Envvar
Tests
Test suite added to
one/src/startup.rs, can be run with the C1 crate:Other notes
It seems to work, but I can't say I fully understand what's going on with the interest builder EventID fencepost ranges. Probably a good spot to focus a review 👀
Closes #707